<template>
  <div>
    <div class="fixContent">
      <div class="info">
        <div class="layerTitle" v-html="value.title">千年一梦镜然西安</div>
        <div class="type">
          <div v-for="(temp,index) in tags(value.tag)" :key="index">{{temp}}</div>
        </div>
        <div class="intro" v-html="value.description"></div>
        <div class="code">
          <img :src="QRCodeImg">
        </div>
        <div class="make">
          <div class="product">
            <span><img src="@/assets/sign.png"></span>
            <span>联合出品:</span>
          </div>
          <div class="part">
            <div v-for="(temp,index) in tags(value.procucer)" :key="index">{{temp}}</div>
          </div>
        </div>
      </div>
      <div class="radius"></div>
    </div>
  </div>
</template>

<script>
import QRCode from "qrcode";
export default {
  props: {
    value: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  data() {
    return {
      QRCodeImg: ""
    };
  },
  watch: {
    value(val) {
      this.createdQRCode(val.href);
    }
  },
  methods: {
    // 生成二维码
    createdQRCode(href = "没有添加链接") {
      if (!href) {
        href = "没有添加链接";
      }
      QRCode.toDataURL(href, { type: "terminal" }, (err, url) => {
        console.log(url);
        this.QRCodeImg = url;
      });
    },
    tags(val) {
      if (!val) return [];
      return val.split(",");
    }
  }
};
</script>

<style lang="less">
.layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 99;
  .radius {
    width: 360px;
    height: 30px;
    background: #fff;
    position: absolute;
    transform: translate(-50%, -50%);
    top: 5px;
    left: 50%;
    border-radius: 15px;
  }
  .fixContent {
    width: 370px;
    // height: 780px;
    background: #e9e9e9;
    position: absolute;
    transform: translate(-50%, -50%);
    top: 20%;
    left: 50%;
    border-radius: 15px;
    z-index: 999;
    .info {
      width: 100%;
      border-radius: 20px;
      background: #e9e9e9;
      padding: 5px 15px;
      box-sizing: border-box;
      position: absolute;
      z-index: 5;
      .layerTitle {
        width: 120px;
        font-size: 30px;
        padding: 20px 0;
        text-align: justify;
        overflow-wrap: break-word;
      }
      .intro {
        // height: 14vw;
        font-size: 14px;
        padding: 15px 0;
        box-sizing: border-box;
      }
      .type {
        display: flex;
        flex-wrap: wrap;
        // padding: 0 0 15px;
        div {
          white-space: nowrap;
          padding: 3px 10px;
          border: 1px solid #444;
          border-radius: 10px;
          font-size: 12px;
          margin: 0 3px 0;
        }
      }
      .code {
        position: relative;
        padding: 10px 100px;
        box-sizing: border-box;
        img {
          width: 100%;
        }
      }
      .make {
        display: flex;
        justify-content: space-between;
        border-top: 1px solid #000;
        padding: 10px 0;
        font-size: 12px;
        .product {
          font-size: 14px;
          img {
            width: 30%;
            vertical-align: middle;
            padding-right: 5px;
          }
        }
      }
    }
  }
}
</style>